<?php

/*
	[SupeSite] (C) 2007-2009 Comsenz Inc.
	$Id: admin_spacenews.php 13513 2009-11-26 07:34:15Z zhaofei $
*/

if(!defined('IN_SUPESITE')) {
	exit('Access Denied');
}

if($_GET['req'] == 'del' && !empty($_GET['no'])){

    $_SGLOBAL['db']->query("DELETE FROM fang_member_collection WHERE house_no = ".$_GET['no']);
    $res = $_SGLOBAL['db']->affected_rows();
}





if(!empty($_SGLOBAL['user']['uid']) && $_GET['req'] == 'rent'){
    $user_id = array('user_id'=>$_SGLOBAL['user']['uid'],'pg'=>$_POST['pg']);

    $modelClass = 'app\com\simtoon\models\Collection';
    $data = YiiComm::executeByMethod($modelClass,'getRent',$user_id);
    $pagin = $data->getPagination();

    $pagin = objectToArray($pagin);
    $AttenHouseResult = $data->getModels();

    $rentJson = array();
    foreach($AttenHouseResult as $val){
        $arr = array('id'=>$val['id'],'structure_area'=>$val['structure_area'],'room_num'=>$val['room_num'],'hall_num'=>$val['hall_num'],'title'=>$val['title'],'house_no'=>$val['house_no'],'rent_listing'=>$val['rent_listing'],'house_driect'=>$val['house_driect'],'floor_count'=>$val['floor_count'],'house_floor'=>$val['house_floor'],'build_year'=>$val['build_year'],'tene_application'=>$val['tene_application'],'domain_name'=>$val['domain_name'],'area_name'=>$val['area_name'],'trade_id'=>$val['trade_id'],'thumb'=>$val['thumb'],'url'=>$val['url'],'comment_title'=>$val['comment_title']);
        $rentJson[] = $arr;
    }
    $rentJson[] = $pagin;
    $rentResult =json_encode($rentJson);
    die($rentResult);
}else if(!empty($_SGLOBAL['user']['uid'])){
    $user_id = array('user_id'=>$_SGLOBAL['user']['uid'],'pg'=>$_GET['pg']);
    $modelClass = 'app\com\simtoon\models\Collection';
    $data = YiiComm::findDataByPagination($modelClass, $user_id);
    $pagin = $data->getPagination();
    $pagin = objectToArray($pagin);
    $AttenHouseResult = $data->getModels();
}
include template('cp_attenhouse');

?>
